<template>
  <el-menu
    class="el-menu"
    router
    mode="horizontal"
    background-color="red"
    text-color="#fff"
    active-text-color="white"
  >
    <el-menu-item class="el-menu-tab" index="/Asset">个人资产</el-menu-item>
    <el-menu-item class="el-menu-tab" index="/StockDetails">股票行情</el-menu-item>
    <el-menu-item class="el-menu-tab" index="/Trade">股票交易</el-menu-item>
    <el-menu-item class="el-menu-tab" index="/History">历史订单</el-menu-item>
    <div>
      <el-button type="text" style="margin: 10px 10px; float:right; color: white" @click="logout">退出</el-button>
    </div>
    <div>
      <el-button type="text" style="margin: 10px 10px; float:right; color: white" @click="login">登录</el-button>
    </div>
  </el-menu>
  <!--  <div id="nav">-->
  <!--    <router-link to="/">Home</router-link> |-->
  <!--    <router-link to="/about">About</router-link>|-->
  <!--    <router-link to="/Stock">Stock</router-link>|-->
  <!--    <router-link to="/login">login</router-link>-->
  <!--  </div>-->
  <router-view/>
</template>

<script lang="js">
import store from './store'
import router from './router'

export default {
  name: 'App',
  data () {
    return {}
  },
  methods: {
    login () {
      if (store.state.userToken === '') {
        router.push('/login')
      }
    },
    logout () {
      if (store.state.userToken !== '') {
        store.commit('REMOVE_INFO')
        router.push('/login')
      }
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
